// For more information about this file see https://dove.feathersjs.com/guides/cli/service.html

import { hooks as schemaHooks } from '@feathersjs/schema'
import {
  gdBaseInfoDataValidator,
  gdBaseInfoPatchValidator,
  gdBaseInfoQueryValidator,
  gdBaseInfoResolver,
  gdBaseInfoExternalResolver,
  gdBaseInfoDataResolver,
  gdBaseInfoPatchResolver,
  gdBaseInfoQueryResolver
} from './gd-base-info.schema.js'
import { GdBaseInfoService, getOptions } from './gd-base-info.class.js'
import { gdBaseInfoPath, gdBaseInfoMethods } from './gd-base-info.shared.js'

export * from './gd-base-info.class.js'
export * from './gd-base-info.schema.js'

// A configure function that registers the service and its hooks via `app.configure`
export const gdBaseInfo = (app) => {
  // Register our service on the Feathers application
  app.use(gdBaseInfoPath, new GdBaseInfoService(getOptions(app)), {
    // A list of all methods this service exposes externally
    methods: gdBaseInfoMethods,
    // You can add additional custom events to be sent to clients here
    events: []
  })
  // Initialize hooks
  app.service(gdBaseInfoPath).hooks({
    around: {
      all: [
        schemaHooks.resolveExternal(gdBaseInfoExternalResolver),
        schemaHooks.resolveResult(gdBaseInfoResolver)
      ]
    },
    before: {
      all: [
        schemaHooks.validateQuery(gdBaseInfoQueryValidator),
        schemaHooks.resolveQuery(gdBaseInfoQueryResolver)
      ],
      find: [],
      get: [],
      create: [
        schemaHooks.validateData(gdBaseInfoDataValidator),
        schemaHooks.resolveData(gdBaseInfoDataResolver)
      ],
      patch: [
        schemaHooks.validateData(gdBaseInfoPatchValidator),
        schemaHooks.resolveData(gdBaseInfoPatchResolver)
      ],
      remove: []
    },
    after: {
      all: []
    },
    error: {
      all: []
    }
  })
}
